package com.neusoft.cmsprojects.service;

import java.util.Collection;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.neusoft.cmsprojects.dao.PrivilegeDao;
import com.neusoft.cmsprojects.model.Privilege;
@Service("privilegeservice")
@Transactional
public class PrivilegeServiceImpl  implements PrivilegeService {

	@Resource(name="privilegedao")
	private PrivilegeDao dao;
	
	@Override
	public List<Privilege> findTopPrivilege() {
		
		return dao.findTopPrivilege();
	}

	@Override
	public Collection<String> getAllPrivilegeUrls() {
		return dao.getAllPrivilegeUrls();
	}

	@Override
	public List<Privilege> getByIds(Integer[] privilegeIds) {
		return dao.getByIds(privilegeIds);
	}

	@Override
	public List<Privilege> findPrivilegeById(Integer id) {
		return dao.findPrivilegeById(id);
	}

	@Override
	public void save(Privilege privilege) {
			dao.save(privilege);
	}

	@Override
	public Privilege getById(Integer parentId) {
		return dao.getById(parentId);
	}

	@Override
	public List<Object> findAll() {
		String hql="from Privilege";
		return dao.queryByHql(hql);
	}

	@Override
	public void delete(Privilege privilege) {
		dao.deleteAndRole(privilege);
	}

	@Override
	public List<Privilege> findChildren(Integer id) {
		String hql="from Privilege p where p.parent="+id+"";
		return dao.findChildren(hql);
	}

	@Override
	public void merge(Privilege privilege) {
		dao.merge(privilege);
	}

}
